package wnhz.com.business.shareshop.activity.home;

import android.content.Intent;
import android.os.Build;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.WindowManager;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import wnhz.com.business.R;
import wnhz.com.business.base.BaseRVAdapter;
import wnhz.com.business.base.BaseViewHolder;
import wnhz.com.business.base.MyBaseActivity;
import wnhz.com.business.impl.ActionBarClickListener;
import wnhz.com.business.rebateshop.activity.home.ShareFriandActivity;
import wnhz.com.business.view.TranslucentActionBar;

/**
 * 天天搞基
 */
public class EverydayPhoneActivity extends MyBaseActivity implements ActionBarClickListener {
    @BindView(R.id.actionbar)
    TranslucentActionBar actionbar;
    @BindView(R.id.rv_everyday_phone)
    RecyclerView rvEverydayPhone;

    private List<String> itemdata = new ArrayList<>();

    @Override
    protected void handleMsg(Message msg) {

    }

    public static Intent createIntent(MyBaseActivity activity) {
        Intent intent = new Intent(activity, EverydayPhoneActivity.class);
        return intent;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_everyday_phone);
        ButterKnife.bind(this);
        actionbar.setData("天天搞机", R.drawable.ic_lefft_white, null, 0, "", 0, this);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            actionbar.setStatusBarHeight(getStatusBarHeight());
        }
        initview();
        initdatabuy();
    }

    private void initview() {
        rvEverydayPhone.setLayoutManager(new GridLayoutManager(getApplication(), 2, GridLayoutManager.VERTICAL, false));
        itemdata.clear();
        for (int i = 0; i < 6; i++) {
            itemdata.add("h" + i);
        }
    }

    private void initdatabuy() {
        rvEverydayPhone.setAdapter(new BaseRVAdapter(this, itemdata) {
            @Override
            public int getLayoutId(int viewType) {
                return R.layout.item_everyday_phone;
            }

            @Override
            public void onBind(BaseViewHolder holder, int position) {
                holder.getView(R.id.item_rl_rebatehome).setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        startActivity(RebateGoodsDetailsActivityS.createIntent(EverydayPhoneActivity.this, "", "", ""));
                    }
                });
                holder.getView(R.id.item_tv_rebatehome_share).setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        //跳转分享页面  (页面标题: 分享商品给好友)
                        startActivity(ShareFriandActivity.createIntent(EverydayPhoneActivity.this));
                    }
                });

            }

        });
    }


    @Override
    public void onLeftClick() {
        finish();
    }

    @Override
    public void onRightClick() {

    }

    @Override
    public void onEditTextClick() {

    }
}
